package com.ruoyi.api.user;

import java.util.HashMap;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ruoyi.api.user.requestVo.AppVersionRequestVo;
import com.ruoyi.framework.web.base.BaseController;
import com.ruoyi.user.domain.App;
import com.ruoyi.user.service.IAppService;

import io.swagger.annotations.ApiOperation;

/**
 * APP版本操作处理
 * @author ruoyi
 * @date 2018-12-23
 */
@Controller
@RequestMapping("/api/app")
public class ApiAppController extends BaseController
{
    private String prefix = "app";
	
	@Autowired
	private IAppService appService;
	
	
	/**
	 * 检查版本接口
	 */
	@PostMapping("/getVersions")
	@ResponseBody
	@ApiOperation(value="检查APP版本", notes="检查APP版本",produces = "application/json")
	public HashMap<String, Object>  getVersions(@RequestBody AppVersionRequestVo vo){
		App param = new App();
		param.setClientType(Integer.valueOf(vo.getClienType()));
		HashMap<String, Object> map = new HashMap<>();
		List<App> list = appService.selectAppList(param);
		if(list!=null&&list.size()>0){
			App app = list.get(0);
			map.put("clienttype", app.getClientType());
			map.put("versionsName", app.getVersionName());
			map.put("versionsCode", app.getVersionCode());
			map.put("down",app.getDownloadUrl()+"/"+app.getVersionName());
			map.put("enabled",app.getIsUseful());
			map.put("isForce",app.getIsForce());
			map.put( "appName", app.getAppName() );
			map.put( "description", app.getDescription() );
		}
		return successApp(map);
	}

}
